package com.rongzhe.house.login.controller;

import com.rongzhe.house.common.resp.ApiResult;
import com.rongzhe.house.login.entity.User;
import com.rongzhe.house.login.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

/**
 * @author Chengjia
 * @date 2018/3/10 16:26
 */
@Controller
@RequestMapping("/register")
public class RegisterController {
    @Autowired
    private LoginService loginService;
    @RequestMapping("/index")
    public String index(){
        return "register";
    }

    @RequestMapping("/validate/mobile")
    @ResponseBody
    public ApiResult validataPhone(User user){
        return loginService.validatePhone(user);
    }

    @RequestMapping("/validate/code")
    @ResponseBody
    public ApiResult validataCode(HttpServletRequest request,String mobile, String imgId, String imgVValue){
        return loginService.validateCode(mobile,imgId,imgVValue,request);
    }

    @RequestMapping("/doRegister")
    @ResponseBody
    public ApiResult doRegister(User user,String vcode){
      return  loginService.doRegister(user,vcode);
    }
}
